/*
 * @Descripttion: 
 * @version: 
 * @Author: kk
 * @Date: 2020-10-13 11:09:34
 * @LastEditors: kk
 * @LastEditTime: 2020-10-26 18:32:59
 */
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: '',
    userInfo: JSON.parse(sessionStorage.getItem("userInfo")),
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token;
      localStorage.setItem("token", token)
    },
    SET_USERINFO: (state, userInfo) => {
      state.userInfo = userInfo
      sessionStorage.setItem("userInfo", JSON.stringify(userInfo))
    },
    REMOVE_INFO: (state) => {
      localStorage.setItem("token", '')
      sessionStorage.setItem("userInfo", JSON.stringify(''))
      state.userInfo = {}
    },
  },
  getters: {
    getUser: state => {
      return state.userInfo
    },
  },
  actions: {},
  modules: {}
})